package com.sanpu.kxe.business.repay.view;

import android.content.Context;
import android.view.View;
import android.widget.GridView;

import com.sanpu.kxe.R;
import com.sanpu.kxe.base.BaseTitleActivity;
import com.sanpu.kxe.business.repay.adapter.RepaySupportAdapter;
import com.sanpu.kxe.business.repay.contract.RepayConfig;
import com.sanpu.kxe.business.repay.contract.RepaySupportContract;
import com.sanpu.kxe.business.repay.presenter.RepaySupportPresenter;
import com.sanpu.kxe.business.trade.bean.SupportBankOutput;

import java.util.List;

import butterknife.Bind;

/**
 * Description：可支持银行
 * Created by 薛勇军 on 2019/4/26.
 */

public class RepaySupportActivity extends BaseTitleActivity implements RepaySupportContract.View {

    @Bind(R.id.supportGv)
    GridView supportGv;
    @Bind(R.id.emptyView)
    View emptyView;

    private RepaySupportAdapter mSupportAdapter;

    private RepaySupportContract.Presenter mPresenter;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_repay_support;
    }

    @Override
    protected void initView() {
        super.initView();
        commonTitle.setTitle("可支持银行");
        String appCnlConfId = getIntent().getStringExtra(RepayConfig.INTENT_APPRTID);

        mSupportAdapter = new RepaySupportAdapter(mContext);
        supportGv.setAdapter(mSupportAdapter);

        mPresenter = new RepaySupportPresenter(this);
        mPresenter.findAppCnlConfBankSupportDetailList(appCnlConfId);
    }

    @Override
    public void showDataView(List<SupportBankOutput> supportBankOutputs) {
        if (supportBankOutputs != null && supportBankOutputs.size() > 0) {
            emptyView.setVisibility(View.GONE);
            supportGv.setVisibility(View.VISIBLE);
            mSupportAdapter.setNotifyData(supportBankOutputs);
        } else {
            emptyView.setVisibility(View.VISIBLE);
            supportGv.setVisibility(View.GONE);
        }
    }

    @Override
    protected boolean hasBindEventBus() {
        return false;
    }

    @Override
    public void setPresenter(RepaySupportContract.Presenter presenter) {
        this.mPresenter = presenter;
    }

    @Override
    public Context getContext() {
        return this;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.onDestroyPresenter();
            mPresenter = null;
        }
    }
}
